Fix forecast displaying "[Object object]" instead of card sides#2
Fix forecast displaying "[Object object]" instead of card sides#2
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Co-authored-by: chand1012 <3521582+chand1012@users.noreply.github.com>
Co-authored-by: chand1012 <3521582+chand1012@users.noreply.github.com>
There was a problem hiding this comment.
Type error in this file. Type error: Parameter 'card' implicitly has an 'any' type.
Please fix so that the vercel build succeeds.
There was a problem hiding this comment.
Fixed the TypeScript error by adding the Initiative type import and properly typing the card parameter in the map function. Also updated to use the existing isGrowthInitiative() helper function for better consistency. The Vercel build should now succeed. (commit 8403ba1)
There was a problem hiding this comment.
Names of forecasted cards should be "growth" and "hostile" not "visionary" and "insider".
There was a problem hiding this comment.
Updated the forecast display to show "growth" and "hostile" card types instead of "Visionary" and "Insider" faction names. The forecast action now properly displays the card types themselves for better clarity. (commit b24a1db)
…rd parameter Co-authored-by: chand1012 <3521582+chand1012@users.noreply.github.com>
chand1012
left a comment
There was a problem hiding this comment.
Names of forecasted cards should be "growth" and "hostile" not "visionary" and "insider".
…ry" and "Insider" Co-authored-by: chand1012 <3521582+chand1012@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
The forecast display has already been updated to show "growth" and "hostile" instead of "Visionary" and "Insider" in commit b24a1db. The code now correctly displays card types rather than faction names. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where the forecast functionality was displaying "[Object object]" instead of the actual card types (growth or hostile) for the next 3 cards in the game.
- Fixed object-to-string conversion issue in forecast display logic
- Updated code to properly map Initiative objects to their readable card types
- Added proper type import for Initiative interface
| if (result.next_cards) { | ||
| message += `\n\nNext 3 cards: ${result.next_cards.join(", ")}`; | ||
| const cardTypes = result.next_cards.map((card: Initiative) => | ||
| isGrowthInitiative(card) ? 'growth' : 'hostile' |
There was a problem hiding this comment.
The card type mapping doesn't match the description. According to the PR description, growth initiatives should map to 'Visionary' and hostile initiatives should map to 'Insider', but the code maps them to 'growth' and 'hostile'.
| isGrowthInitiative(card) ? 'growth' : 'hostile' | |
| isGrowthInitiative(card) ? 'Visionary' : 'Insider' |
The forecast functionality was displaying "[Object object]" three times instead of showing the side of the next 3 cards (insider or visionary) as intended.
Root Cause
In
components/game-controller.tsx, the code was attempting to join an array of Initiative objects directly:But
result.next_cardsis an array of Initiative objects with{type, text}properties, not strings. When JavaScript converts objects to strings in a join operation, they become "[object Object]".Solution
Modified the forecast display logic to properly map Initiative objects to their meaningful card sides:
Test Results
The forecast action is available to COOs after 3 hostile initiatives have been passed, and now properly displays whether each upcoming card benefits the Visionary faction (growth initiatives) or Insider faction (hostile initiatives).
Fixes #1.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
fonts.googleapis.com/usr/local/bin/node /home/REDACTED/work/hostile-takeover/hostile-takeover/node_modules/next/dist/compiled/jest-worker/processChild.js(dns block)next-server (v15.3.2)(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.